//
//  NSUserDefaults+UserInfo.h
//  newBooks
//
//  Created by 张 on 2018/11/21.
//  Copyright © 2018年 pro2. All rights reserved.
//

#import "NSUserDefaults+UserInfo.h"
@implementation NSUserDefaults (UserInfo)

//是否自动登录
- (void)setAutoLogin:(BOOL)autoLogin
{
    if (autoLogin) {
        [self setBool:autoLogin forKey:@"AUTOLOGIN"];
    }else{
        [self removeObjectForKey:@"AUTOLOGIN"];
    }
    [self synchronize];
}
- (BOOL)getAutoLogin
{
    return [self boolForKey:@"AUTOLOGIN"];
}

//ID
- (void)setUserID:(NSString *)userID{
    if (userID) {
        [self setObject:userID forKey:@"USER_ID"];
    }else{
        [self removeObjectForKey:@"USER_ID"];
    }
    [self synchronize];
}
- (NSString *)getUserID{
    return [self objectForKey:@"USER_ID"] ? [self objectForKey:@"USER_ID"] : @"";
}

//用户头像
- (void)setUserImage:(NSString *)userImage
{
    if (userImage) {
        [self setObject:userImage forKey:@"USERIMAGE"];
    }else{
        [self removeObjectForKey:@"USERIMAGE"];
    }
    [self synchronize];
}
- (NSString *)getUserImage
{
    return [self objectForKey:@"USERIMAGE"];
}

//用户账户
- (void)setUserMobile:(NSString *)mobile{
    if (mobile) {
        [self setObject:mobile forKey:@"USER_USERNAME"];
    }else{
        [self removeObjectForKey:@"USER_USERNAME"];
    }
    [self synchronize];
}
- (NSString *)getUserMobile{
    return [self objectForKey:@"USER_USERNAME"];
}

//用户描述
- (void)setUserIntroduce:(NSString *)introduce
{
    if (introduce) {
        [self setObject:introduce forKey:@"USERINTRODUCE"];
    }else{
        [self removeObjectForKey:@"USERINTRODUCE"];
    }
    [self synchronize];
}
- (NSString *)getIntroduce
{
    if ([NSString stringWithFormat:@"%@",[self objectForKey:@"USERINTRODUCE"]].length == 0) {
        return @"此人还不错，没什么好说的";
    }else{
        
        return [self objectForKey:@"USERINTRODUCE"];
    }
}

//用户姓名
- (void)setUserRealName:(NSString *)userName{
    if (userName) {
        [self setObject:userName forKey:@"USER_RealName"];
    }else{
        [self removeObjectForKey:@"USER_RealName"];
    }
    [self synchronize];
}

- (NSString *)getUserRealName{
    return [self objectForKey:@"USER_RealName"];
}

//用户密码
- (void)setPassword:(NSString *)password{
    if (password) {
        [self setObject:password forKey:@"USER_PASSWORD"];
    }else{
        [self removeObjectForKey:@"USER_PASSWORD"];
    }
    [self synchronize];
}
- (NSString *)getPassword{
    return [self objectForKey:@"USER_PASSWORD"];
}

//accessToken
- (void)setAccessToken:(NSString *)accessToken
{
    if (accessToken) {
        [self setObject:accessToken forKey:@"AccessToken"];
    }else{
        [self removeObjectForKey:@"AccessToken"];
    }
    [self synchronize];
}

- (NSString *)getAccessToken
{
    return [self objectForKey:@"AccessToken"];
}


@end


